package structures.trees;

/**
 * An object that allows the storage of integers in a Binary Tree
 */
public class TreeValueInteger implements ITreeValue {
    
    // The integer value
    private Integer value;
    
    /**
     * Constructor for the TreeValueInteger
     * @param value Primitive integer value to be stored
     */
    public TreeValueInteger(int value) {
        this.value = Integer.valueOf(value);
    }
    
    /**
     * Returns an Integer object with the stored value
     * @return The stored integer object
     */
    public Integer getValue() {
        return this.value;
    }
    
    /**
     * Prints the value
     */
    public void print() {
        if(value == null)
            System.out.print("null ");
        else
            System.out.print(this.value + " ");
    }
    
    public int compareTo(Object o) {
        if(this.value < ((TreeValueInteger)o).getValue())
            return -1;
        else if(value == ((TreeValueInteger)o).getValue())
            return 0;
        else
            return 1;
    }
}
